Skip to content

Conversation

@herbhuang
Copy link

This PR seeks to resolve #148.

problem statement

Starting from semTools 0.5-7, monteCarloCI() generates the normal distribution sample with mnormt::rmnorm rather than MASS::mvrnorm. However, there is a slight difference in the values produced by functions from both packages.

  • mnormt::rmnorm returns matrix with column names from colname(ACM) (if there is, otherwise X1-XN )
  • MASS::nvrnorm returns matrix with column names from names(coefs) forcefully

To avoid this, users have to rewrite their code by assigning column names from names(coefs) manually. I added one line of code to restore the column names from coefs so that users do not need to change their code after updating semTools.

internal behavior

mnormt::rmnorm

> new_unamed <- data.frame(mnormt::rmnorm(n = nRep, mean = coefs, varcov = unnamed))
> names(new_unamed)
[1] "X1" "X2" "X3"
> new_named <- data.frame(mnormt::rmnorm(n = nRep, mean = coefs, varcov = named))
> names(new_named)
[1] "a" "b" "c"

MASS::mvrnorm

> old_unnamed <- data.frame(MASS::mvrnorm(n = nRep, mu = coefs, Sigma = unnamed))
> names(old_unnamed)
[1] "a" "b" "c"
> old_named <- data.frame(MASS::mvrnorm(n = nRep, mu = coefs, Sigma = named))
> names(old_named)
[1] "a" "b" "c"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

semTools::monteCarloCI() Error: object not found

1 participant